"use strict";
module.exports = function (sequelize, DataTypes) {
    var Project = sequelize.define("Project", {
        name: {
            type: DataTypes.STRING,
            field: 'Name'
        },
        date: {
            type: DataTypes.DATE,
            field: 'Date'
        },
        id: {
            type: DataTypes.INTEGER,
            field: 'Id',
            autoIncrement: true,
            primaryKey: true
        }
    }, {
            freezeTableName: true,
            timestamps: false,
            classMethods: {
                associate: function (models) {
                    //全站仪配置
                    Project.hasMany(models.StationConfig, {
                        foreignKey: "PrjId"
                    });
                    //测距仪配置
                    Project.hasMany(models.DistDeviceConfig, {
                        foreignKey: "PrjId"
                    });
                    //倾角计配置
                    Project.hasMany(models.AngleDeviceConfig, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.ManualCenter, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.SurveyCenter, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.DesignCenter, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.SectionConfig, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.CoorDiff, {
                        foreignKey: "PrjId"
                    });
                    Project.hasMany(models.AngleCoorDiff, {
                        foreignKey: "PrjId"
                    });

                }
            }
        });
    return Project;
};